package com.fhmoralles.senha;

import java.io.Serializable;
import java.util.List;

import javax.enterprise.context.SessionScoped;
import javax.inject.Inject;
import javax.inject.Named;

import com.fhmoralles.senha.dominio.Fila;
import com.fhmoralles.senha.dominio.Vagas;
import com.fhmoralles.senha.negocio.espec.FilaNegocio;
import com.fhmoralles.senha.negocio.espec.VagasNegocio;

@Named
@SessionScoped
public class ChamadoViewUI implements Serializable {

	private int number = 0;
	private boolean rendered = false;
	private String senha = null;
	
	/* Negoico */
	@Inject
	private VagasNegocio vagasNegocio;
	List<Vagas> vagas;
	
	@Inject
	private FilaNegocio filaNegocio;
	
    public boolean isRendered() {
		return rendered;
	}

	public int getNumber() {
        return number;
    }

    public String getSenha() {
		return senha;
	}

	public List<Vagas> getVagas() {
		return vagas;
	}

	public void increment() {

		rendered = false;
		vagas = null;
		List<Fila> filas = filaNegocio.retrieveAll();
		
		if(filas != null) {
			
			if(filas.size() > 0) {
				
				rendered = true;
				Fila fila = filas.get(0);
		        senha = "senha" + fila.getVaga() + ".jpg";
		        
		        vagas = vagasNegocio.retrieveAll();
				
			}
		}
    }
}
